/**
 * 
 */
package com.lanswon.qzsmk.service.cardManageService.impl;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.UnavailableSecurityManagerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.lanswon.qzsmk.base.AccountContants;
import com.lanswon.qzsmk.base.AppContants;
import com.lanswon.qzsmk.base.CardContants;
import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.dao.AppKindMapper;
import com.lanswon.qzsmk.dao.AppOpenRegMapper;
import com.lanswon.qzsmk.dao.BusiParamMapper;
import com.lanswon.qzsmk.dao.BusinessMapper;
import com.lanswon.qzsmk.dao.CardControlMapper;
import com.lanswon.qzsmk.dao.CardDataMapper;
import com.lanswon.qzsmk.dao.CardManageMapper;
import com.lanswon.qzsmk.dao.CardProdunctDefinitionMapper;
import com.lanswon.qzsmk.dao.CardTypeMapper;
import com.lanswon.qzsmk.dao.CertMapper;
import com.lanswon.qzsmk.dao.CertificateMapper;
import com.lanswon.qzsmk.dao.ChangeCardMapper;
import com.lanswon.qzsmk.dao.DepositMapper;
import com.lanswon.qzsmk.dao.FeeRulesMapper;
import com.lanswon.qzsmk.dao.MainAccountPersonalMapper;
import com.lanswon.qzsmk.dao.SubaccountPersonalMapper;
import com.lanswon.qzsmk.dao.TransGlideMapper;
import com.lanswon.qzsmk.dao.TxnDtlMapper;
import com.lanswon.qzsmk.exception.ApplicationException;
import com.lanswon.qzsmk.exception.ErrorCode;
import com.lanswon.qzsmk.model.ActiveUser;
import com.lanswon.qzsmk.model.AppKind;
import com.lanswon.qzsmk.model.AppOpenReg;
import com.lanswon.qzsmk.model.Business;
import com.lanswon.qzsmk.model.CardControl;
import com.lanswon.qzsmk.model.CardData;
import com.lanswon.qzsmk.model.CardManage;
import com.lanswon.qzsmk.model.Cert;
import com.lanswon.qzsmk.model.ChangeCard;
import com.lanswon.qzsmk.model.SubaccountPersonal;
import com.lanswon.qzsmk.model.TransGlide;
import com.lanswon.qzsmk.model.TxnDtl;
import com.lanswon.qzsmk.service.cardManageService.CancelCardService;
import com.lanswon.qzsmk.service.preService.BikeService;
import com.lanswon.qzsmk.util.SequenceNumberUtil;
import com.lanswon.qzsmk.vo.AppAcVo;
import com.lanswon.qzsmk.vo.AppFeeVo;
import com.lanswon.qzsmk.vo.CancelCardInfo;
import com.lanswon.qzsmk.vo.DepositVo;
import com.lanswon.qzsmk.vo.VoucherVo;

/**
 * @author sun
 *
 */
@Service
public class CancelCardServiceImpl implements CancelCardService {
	

	@Autowired
	FeeRulesMapper frsm;
	
	@Autowired
	CertificateMapper cm;

	@Autowired
	CardProdunctDefinitionMapper cpdm;

	@Autowired
	ChangeCardMapper ccm;

	@Autowired
	CardTypeMapper ctm;

	@Autowired
	CardControlMapper cacm;

	@Autowired
	CardDataMapper cdm;

	@Autowired
	CardManageMapper cmm;

	@Autowired
	BusinessMapper bm;

	@Autowired
	CertMapper cem;
	
	@Autowired
	AppOpenRegMapper aorm;
	
	@Autowired
	SubaccountPersonalMapper spm;
	
	@Autowired
	TxnDtlMapper tdm;
	
	@Autowired
	BusiParamMapper bpm;
	
	@Autowired
	AppKindMapper akm;
	
	@Autowired
	MainAccountPersonalMapper mapm;

	@Autowired
	TransGlideMapper tgm;
	
	@Autowired
	DepositMapper dem;
	
	@Autowired
	BikeService bikeService;

	@Override
	public DwzPage<CancelCardInfo> queryCancelCard(CancelCardInfo lci) {
		lci.setCardStatus(CardContants.CARD_STATE_NORMAL);
		 lci.setCardTypeCode(CardContants.CARD_TYPE_ANONYMOUS);
		 lci.setCertStatus(CardContants.CERT_STATUS_VALID);
//		lci.setCardStatus2(CardContants.CARD_STATE_OFFICIAL_LOSS);
		List<ChangeCard> list = ccm.queryCancelCard(lci);
		List<CancelCardInfo> l = new ArrayList<>();

		for (ChangeCard c1 : list) {
			CancelCardInfo c2 = new CancelCardInfo();
			c2.setCardPName(cpdm.queryCardPCode(c1.getCardpCode())
					.getCardpName());
			c2.setCardStatusName(CardContants.getCardStatusNameByCode(c1.getCardStatus()));
			c2.setCardStatus(c1.getCardStatus());
			c2.setCitizenCardNo(c1.getCitizenCardNo());
			c2.setPaperNo(c1.getPaperNo());
			c2.setPaperTypeName(cm.queryCertificateByCode(c1.getPaperType())
					.getCertificatesName());
			c2.setCustomerName(c1.getCustomerName());
			c2.setCardTypeName(ctm.queryCardTypeByCode(c1.getCardTypecode())
					.getCardTypeName());
			c2.setCardTypeCode(c1.getCardTypecode());
			l.add(c2);
				
		}
		int totalCount = ccm.queryCancelCardCount(lci);
		DwzPage<CancelCardInfo> dp = new DwzPage<CancelCardInfo>(
				lci.getCurrentPage(), lci.getNumPerPage(), totalCount);
		dp.setList(l);

		return dp;

	}
	
	@Override
	public CancelCardInfo queryPersonalInfo(CancelCardInfo cci) throws Exception{
		if(StringUtils.isEmpty(cci.getCardPName()) || StringUtils.isEmpty(cci.getCitizenCardNo())){
			throw new ApplicationException(ErrorCode.OBJECT_IS_NULL, "cardPName or CitizenCardNo is  null!!!");
		}
		CancelCardInfo cc = new CancelCardInfo();
		Short validTime = cpdm.queryCardPCodeByCardProductName(cci.getCardPName()).getCardValidTime();
		cc.setCardQualityAssurance(validTime.toString());
		
		
//		int refundDays =  bpm.queryBusiParamByCitizenCardNo(cci.getCitizenCardNo()).getRecRefundDay();
//		Calendar c = Calendar.getInstance();
//		c.setTime(new Date());
//		c.add(Calendar.DAY_OF_MONTH, refundDays);// 今天+n天
//		cc.setExpectedRefundsDate(c.getTime());
		
		return cc;
	}
	

	@Transactional(rollbackFor=Exception.class,propagation = Propagation.REQUIRED)
	@Override
	public VoucherVo commitCancelCardInfo(CancelCardInfo lci) throws ApplicationException {
		
		ActiveUser activeUser = null;
		try {
			activeUser = (ActiveUser) SecurityUtils.getSubject().getSession().getAttribute("activeUser");

		} catch (UnavailableSecurityManagerException e) {
			e.printStackTrace();
			activeUser = new ActiveUser();
			activeUser.setUserName("用户");
			activeUser.setLoginName("用户");
			activeUser.setBranchName("互联网端");
			activeUser.setBranchNo("99999999");
			activeUser.setUserNo(99999999);
			activeUser.setUserId(99999999);
		}
		
		if(activeUser == null){
			activeUser = new ActiveUser();
			activeUser.setUserName("用户");
			activeUser.setLoginName("用户");
			activeUser.setBranchName("互联网端");
			activeUser.setBranchNo("99999999");
			activeUser.setUserNo(99999999);
			activeUser.setUserId(99999999);
		}
		Date currentTime = new Date();
		VoucherVo vv = new VoucherVo();
		Map<String, Object> map = new HashMap<>();
		CardControl cc = cacm.queryCardControlByCitizenCardNo(lci
				.getCitizenCardNo());

		CardData cd = cdm.queryCardDataById(cc.getCardDataId());

		
		
	
		
		
		List<AppOpenReg> aors = aorm.queryAppOpenRegByCitizenCardNo(lci.getCitizenCardNo(),AppContants.APP_STATUS_OPEN);
		List<AppFeeVo> aors_fee = aorm.queryAppOpenRegAboutFee(lci.getCitizenCardNo(), AccountContants.FEE_TYPE_DEPOSIT, AppContants.APP_STATUS_OPEN);
		for(AppOpenReg aor:aors){
			aor.setStopDate(currentTime);
			aor.setAppStatus(AppContants.APP_STATUS_CLOSE);
			aor.setRemark("注销卡片,关闭应用");
			aor.setLastOperator(activeUser.getUserNo().toString());
			aor.setLastDate(currentTime);
			aor.setIsDeposit(AccountContants.IS_DEPOSIT_YES);
			aorm.update(aor);
		}
		
		List<SubaccountPersonal> sps = spm.querySubaccountPersonalByCitizenCardNo(lci.getCitizenCardNo());//子账户
		//钱包1
		
		for(SubaccountPersonal cardWallet:sps){
			cardWallet.setAccountStatus(AccountContants.ACCOUNT_STATUS_CANCEL_ACCOUNT);//帐号状态
//			cardWallet.setAcType(AccountContants.WALLET_TYPE_ELECTRONIC_BANKBOOK);// 所属钱包类型id 01-电子存折  02-电子钱包
			cardWallet.setClsDate(currentTime);//销户日期 
			cardWallet.setClsTellerNo(activeUser.getUserNo().toString());//销户柜员号
//			cardWallet.setFreezeStatus(AccountContants.ACCOUNT_STATUS_CANCEL_ACCOUNT);// 冻结标志
			cardWallet.setLossStatus(AccountContants.STATUS_VALID);//挂失状态
			cardWallet.setRemark("注销卡钱包");
			spm.update(cardWallet);
		}
		
		
		
		
//		   有卡注销 退款押金
		//每一个应用退一次押金
		
		for(AppFeeVo appFeeVo:aors_fee){
			if(appFeeVo.getAppFlag().equals(AppContants.APP_FLAG_BIKE)){
				
			}else{
				
				Cert ce = new Cert();
				ce.setCertType(CardContants.REFUND_REGISTRATION_DEPOSIT);
				ce.setCertNo(SequenceNumberUtil.generatorCertNo());
				ce.setCardpCode(cd.getCardpCode());
				ce.setCardTypecode(cd.getCardTypecode());
				ce.setName(lci.getCustomerName());
				ce.setPaperNo(lci.getPaperNo());
				ce.setPaperType(lci.getPaperType());
				ce.setBranch(activeUser.getBranchName());
				ce.setBranchNo(activeUser.getBranchNo());
				ce.setAgentName(lci.getAgentName());
				ce.setAgentPaperNo(lci.getAgentPaperNo());
				ce.setAgentPapertype(lci.getAgentPapertype());
				ce.setCardControlId(cc.getCardControlId());
				ce.setCrtDate(currentTime);
				ce.setCrtOperator(activeUser.getUserNo().toString());
				ce.setLastOperator(activeUser.getUserNo().toString());
				ce.setLastDate(currentTime);
				
				
				//业务流水
				Business b = new Business();
				b.setBusinessNo(SequenceNumberUtil.generatorBusinessNo());
				b.setCertNo(ce.getCertNo());
				b.setCustomerNo(cd.getCustomerNo());
				b.setTransCode("交易代码");
				b.setAgentName(lci.getAgentName());
				b.setAgentPaperNo(lci.getAgentPaperNo());
				b.setAgentPapertype(lci.getAgentPapertype());
				b.setAgentPhone(lci.getAgentPhone());
				b.setBusiNum(1);
				b.setTellerNo(activeUser.getUserNo().toString());
				b.setTransDate(currentTime);// 交易日期
				b.setSeqStatus(CardContants.LSZT_NORMAL);
				b.setRemark(lci.getRemark());
				b.setCardControlId(cc.getCardControlId());
				bm.insert(b);
				
				ce.setBusinessNo(b.getBusinessNo());
				cem.insert(ce);
				
				//交易明细流水
				TransGlide tg = new TransGlide();
				tg.setAcceptTp(AccountContants.ACCEPTANCE_TYPE_NET);//受理类型
//				tg.setAccountType(accountType);//账户类型
				tg.setAllowReturn(AccountContants.STATUS_VALID);//不可退费
//				tg.setAppFlag(appFlag);//应用标识
				tg.setAppType(appFeeVo.getAppType());//应用类型 
				tg.setBranchNo(activeUser.getBranchNo());
//				tg.setBusinessNo(businessNo);//业务流水号
//				tg.setCardSeqNo(cardSeqNo);//卡片序列号
				tg.setCashFlag(AccountContants.CASH_FLAG_PAY);//现金收付标志 
				tg.setFeeRuleId(appFeeVo.getFeeRuleId());//卡费用规则ID
				tg.setFeeRulesId(appFeeVo.getFeeRulesId());//卡费用细则ID
				tg.setFeeTp(AccountContants.FEE_TYPE_DEPOSIT);//费用类型
				tg.setIsReturned(AccountContants.STATUS_VALID);//是否已退费
				tg.setOprNo(activeUser.getUserNo().toString());
				tg.setPaymentType(AccountContants.PAYMENT_TYPE_CASH);//现金
				
				tg.setPaymentTypeExt(AccountContants.STATUS_INVALID);
//				tg.setRptDate(rptDate);//轧帐日期
				tg.setRptFlag(AccountContants.RPT_FLAG_NO);//轧帐标识  0未过账
//				tg.setSubaccountNo(subaccountNo);//网点子账号
//				tg.setReturnTransGlideId(returnTransGlideId);//退费交易明细流水ID
				tg.setTxnAdjFlg(AccountContants.TRANSACTION_FLOW_FLAG_NORMAL);//交易流水标识
//				tg.setTxnAmt(txnAmt);//交易金额 --获取押金
				tg.setTxnDt(currentTime);//交易时间 
//				tg.setTxnTp(txnTp);//txnTp 交易类型
				tg.setBusinessNo(b.getBusinessNo());
				tgm.insert(tg);
				
				TxnDtl td_deposit = new TxnDtl();
				td_deposit. setCitizenCardNo(lci.getCitizenCardNo());
				td_deposit. setIssCityCd(CardContants.CITY_CODE);		
				td_deposit. setTxnCityCd(CardContants.CITY_CODE) ;
				td_deposit. setAppFlag(AppContants.APP_FLAG_BIKE);
				td_deposit. setCrdPhysTp(cd.getCardPhysicalType()) ;//卡物理类型 		  
				td_deposit. setCashFlag(AccountContants.CASH_FLAG_PAY); //现金收付标志 0.无,1.收取 2.支出,3.收支
//				td_deposit. setTxnTp(bv.getCrdTxnType());//	卡交易类型 02 06
				td_deposit. setTxnDt(DateFormatUtils.format(currentTime, "yyyyMMddHHmmss"));			   
				td_deposit. setTxnBalBef(new BigDecimal(0)) ;//账户交易前余额		 
				td_deposit. setTxnBalAft(new BigDecimal(0));			    
				td_deposit. setTxnAmt(appFeeVo.getFeeBln()) ;			  
				td_deposit. setFeeTp(AccountContants.FEE_TYPE_DEPOSIT);//费用类型  0.本金 1:工本费 2.交易手续费 3:租金4:押金			    
				td_deposit. setAcceptTp(AccountContants.ACCEPTANCE_TYPE_NET);
				td_deposit. setAcceptCusNo(activeUser.getBranchNo()) ;//受理商户/网点编号			  
			    td_deposit. setTxnTstFlg(AccountContants.TRANSACTION_TEST_FLAG_COMMON) ;//交易测试标志 "0"-普通; "1"-测试			   
			    td_deposit. setTxnAdjFlg(AccountContants.TRANSACTION_FLOW_FLAG_NORMAL);//交易流水标志 "00" 正常 "41" 撤销			   
			    td_deposit. setWarrantid(ce.getCertNo()) ;//凭证号
			    td_deposit. setOprNo(activeUser.getUserNo().toString());//操作员编号/终端操作员编号 			  
			    td_deposit. setTxnAttr(AccountContants.TXNTP_REFUND) ;//交易性质 			   
			    td_deposit. setCrdCityCd(CardContants.CITY_CODE);//卡城市代码
			    td_deposit. setCardType(cd.getCardTypecode());
			    td_deposit. setRsvdFlags(AccountContants.TXNTP_REFUND);	//预留标志组		   
			    td_deposit. setTxnType(AccountContants.TRADE_TYPE_BIKE) ;//终端交易类型 
			    td_deposit. setTxnDate(DateFormatUtils.format(currentTime, "yyyyMMdd")) ;	//交易日期		   
			    td_deposit. setBusinessNo(td_deposit.getBusinessNo());//
			    td_deposit. setPaymentType(AccountContants.PAYMENT_TYPE_CASH);//支付方式  0 现金 1 兑换券  默认为0
			    td_deposit. setPaymentTypeExt(AccountContants.STATUS_INVALID);//支付方式是否扩展 0 否1 是  默认为0
			    td_deposit. setRealTxnAmt(appFeeVo.getFeeBln());
			}
			
			
		}
		
		
		
		Cert ce = new Cert();
		if (CardContants.CARD_IS_READ.equals(lci.getIsRead())) {// 可读
			ce.setCertType(CardContants.SPOT_REFUND);
			
		} else if (CardContants.CARD_NO_READ.equals(lci.getIsRead())) {
			ce.setCertType(CardContants.SPOT_REFUND);
		}
		ce.setCertNo(SequenceNumberUtil.generatorCertNo());
		ce.setCardpCode(cd.getCardpCode());
		ce.setCardTypecode(cd.getCardTypecode());
		ce.setName(lci.getCustomerName());
		ce.setPaperNo(lci.getPaperNo());
		ce.setPaperType(lci.getPaperType());
		ce.setBranch(activeUser.getBranchName());
		ce.setBranchNo(activeUser.getBranchNo());
		ce.setAgentName(lci.getAgentName());
		ce.setAgentPaperNo(lci.getAgentPaperNo());
		ce.setAgentPapertype(lci.getAgentPapertype());
		ce.setCardControlId(cc.getCardControlId());
		ce.setCrtDate(new Date());
		ce.setCrtOperator(activeUser.getUserNo().toString());
		ce.setLastOperator(activeUser.getUserNo().toString());
		ce.setLastDate(new Date());
		

		//业务流水
		Business b = new Business();
		b.setBusinessNo(SequenceNumberUtil.generatorBusinessNo());
		b.setCertNo(ce.getCertNo());
		b.setCustomerNo(cd.getCustomerNo());
		b.setTransCode("交易代码");
		b.setAgentName(lci.getAgentName());
		b.setAgentPaperNo(lci.getAgentPaperNo());
		b.setAgentPapertype(lci.getAgentPapertype());
		b.setAgentPhone(lci.getAgentPhone());
		b.setBusiNum(1);
		b.setTellerNo(activeUser.getUserNo().toString());
		b.setTransDate(currentTime);// 交易日期
		b.setSeqStatus(CardContants.LSZT_NORMAL);
		b.setRemark(lci.getRemark());
		b.setCardControlId(cc.getCardControlId());
		bm.insert(b);
		
		ce.setBusinessNo(b.getBusinessNo());
		cem.insert(ce);
		
		CardManage cm = new CardManage();

		cm.setProcessId(UUID.randomUUID().toString().replace("-", ""));
		cm.setCustomerNo(cd.getCustomerNo());
		cm.setCardpCode(cd.getCardpCode());

		cm.setCardPosition(CardContants.CARD_POSITION_CITIZEN);
		cm.setCardStatus(CardContants.CARD_STATE_CANCELLATION_HAS_CARD);
		cm.setProcessName("卡注销");
		cm.setCardTypecode(cd.getCardTypecode());
		cm.setApplyBranch(activeUser.getBranchName());
		cm.setApplyBranchNo(activeUser.getBranchNo());
		cm.setApplyDate(currentTime);
		cm.setApplyTellerNo(activeUser.getUserNo().toString());
		cm.setRemark(lci.getRemark());
		

		cm.setCertNo(ce.getCertNo());
		cm.setBusinessNo(b.getBusinessNo());
		cmm.insert(cm);
		
		if (CardContants.CARD_IS_READ.equals(lci.getIsRead())) {// 可读
			cc.setCardStatus(CardContants.CARD_STATE_CANCELLATION_HAS_CARD);
		} else if (CardContants.CARD_NO_READ.equals(lci.getIsRead())) {
			cc.setCardStatus(CardContants.CARD_STATE_CANCELLATION_NO_CARD);
		}
		cc.setClaimStatus(CardContants.CLAIM_STATUS_CANCEL);	
		
		cc.setCardPosition(CardContants.CARD_POSITION_COUNTER_EMPLOYEE);
		cc.setCurrProcId(cm.getProcessId());
		cc.setLogoutDate(currentTime);
		cc.setLogoutReason(lci.getLogoutReason());
		cc.setLastDate(currentTime);
		cc.setLastOperator(activeUser.getUserNo().toString());
		cacm.updateCardControl(cc);
		
		
		
		for(AppFeeVo appFeeVo:aors_fee){
			if(appFeeVo.getAppFlag().equals(AppContants.APP_FLAG_BIKE)){
				VoucherVo vo = bikeService.closeBikeApp(lci.getCitizenCardNo());
			}
			
		}
		String str = "{\"title\":\""+"注销凭证"+"\",\"type\":\""+"logoffCardRegister"+"\",\"certNo\":\""+ce.getCertNo()+"\",\"busType\":\""
		+CardContants.getCertTypeNameByCode(ce.getCertType())+"\",\"cardType\":\""+ce.getCardTypecode()+"\",\"citizenCardNo\":\""
		+lci.getCitizenCardNo()+"\",\"fee\":\""+(new DecimalFormat("0.00")).format(Integer.valueOf(lci.getBalance()))+"\",\"money\":\""
		+(new DecimalFormat("0.00")).format(Integer.valueOf(lci.getRefundMoney()))+"\",\"net\":\""+activeUser.getBranchName()+"\",\"operator\":\""
		+activeUser.getUserNo().toString()+"\",\"date\":\""+DateFormatUtils.format(new Date(), "yyyy-MM-dd")+"\"}";
		ce.setData(str);
		ce.setTransCode("注销登记");
		cem.update(ce);
		
		vv.setCertNo(ce.getCertNo());
		vv.setBusinessTypeName(CardContants.getCertTypeNameByCode(ce.getCertType()));
		vv.setOldCitizenCardNo(lci.getCitizenCardNo());
//		vv.setExpectCardDate(sci.getGetCardDate());
		vv.setDate(DateFormatUtils.format(new Date(),"yyyy-MM-dd"));
		vv.setOperator(ce.getCrtOperator());
		vv.setNet(ce.getBranch());
		vv.setCardType(cd.getCardTypecode());
		vv.setTransactionAmount(String.valueOf((new DecimalFormat("0.00")).format(Integer.valueOf(lci.getRefundMoney()))));//退款总额
		vv.setFeeBln(String.valueOf((new DecimalFormat("0.00")).format(Integer.valueOf(lci.getBalance()))));
		return vv;
		
	}

	@Override
	public List<AppAcVo> queryAppFlagAndWalletType(String citizenCardNo) {
		List<AppOpenReg> apps = aorm.queryAppOpenRegByCitizenCardNo(citizenCardNo,AppContants.APP_STATUS_OPEN);
		List<AppAcVo> appflags = new ArrayList<>();
		for(AppOpenReg app :apps){
			AppAcVo acVo=new AppAcVo();
			AppKind ak = akm.queryAppKindByTypeCode(Integer.valueOf(app.getAppType()));
			acVo.setAppFlag(ak.getAppFlag());
			List<SubaccountPersonal> sps=spm.querySubaccountPersonalByAppFlag(ak.getAppFlag(), citizenCardNo);
			Map<String,BigDecimal>map=new HashMap<>();
			for(SubaccountPersonal s:sps){
				map.put(s.getAcType(), s.getTotalBalance());
			}
			acVo.setWalletType_1(map);
			appflags.add(acVo);
		}
		return appflags;
	}

	@Override
	public DepositVo queryNominalfee(DepositVo depositVo) throws Exception {
		DepositVo depositVo2=null;
		depositVo.setFeeType(AccountContants.FEE_TYPE_NOMINAL_FEE);
		depositVo.setNow(new Date());
		depositVo2=dem.queryNominalfee(depositVo);
		if(depositVo2==null){
			throw new ApplicationException(ErrorCode.FEERULES_NOT_EXIST, "工本费过期或者不存在");
		}
		return depositVo2;
	}

	@Override
	public List<DepositVo> queryDeposit(DepositVo depositVo) throws Exception {
		depositVo.setFeeType(AccountContants.FEE_TYPE_DEPOSIT);
		depositVo.setNow(new Date());
		List<DepositVo> list=dem.queryDeposit(depositVo);
		if(list==null||list.size()==0){
			return new ArrayList<DepositVo>();
		}
		return list;
	}

}
